{{Extend "layout"}}
{{Block "title"}}{{"产品管理"|T}}{{/Block}}
{{Block "breadcrumb"}}
{{Super}}
<li class="active">{{"产品管理"|T}}</li>
{{/Block}}
{{Block "main"}}
<div class="row">
	<div class="col-md-12">
		<div class="block-flat">
			<div class="header">
				<a href="__BACKEND__/official/pay/product_add" class="btn btn-success pull-right">
					<i class="fa fa-plus"></i>
					{{"添加产品"|T}}
				</a>
				<a href="__BACKEND__/official/pay/product_attr_add" class="btn btn-info pull-right">
					<i class="fa fa-plus"></i>
					{{"添加属性"|T}}
				</a>
				<a href="__BACKEND__/official/pay/product_attr_index" class="btn btn-primary pull-right">
					<i class="fa fa-list"></i>
					{{"属性管理"|T}}
				</a>
				<h3>{{"产品列表"|T}}</h3>
			</div>
			<div class="content">
				<div class="table-responsive">
				<table class="table no-border hover">
					<thead class="no-border">
						<tr>
							<th style="width:60px"><strong>ID</strong></th>
							<th style="width:50px"><strong>{{"图"|T}}</strong></th>
							<th><strong>{{"名称"|T}}</strong></th>
							<th style="width:150px"><strong>{{"唯一标识"|T}}</strong></th>
							<th style="width:100px"><strong>{{"价格"|T}}</strong></th>
							<th style="width:70px"><strong>{{"状态"|T}}</strong></th>
							<th style="width:170px"><strong>{{"时间"|T}}</strong></th>
							<th style="width:180px" class="text-center"><strong>{{"操作"|T}}</strong></th>
						</tr>
					</thead>
					<tbody class="no-border-y">
                        {{range $k,$v := Stored.listData}}
						<tr>
							<td>{{$v.Id}}</td>
							<td class="no-padding"><a href="__FRONTEND__/product/detail/{{$v.Ident}}" target="_blank"><img style="width:50px;height:50px" src="{{$v.Image|Default "__ASSETS__/images/user_128.png"}}" onerror="this.src='__ASSETS__/images/user_128.png';" /></a></td>
							<td><a href="__FRONTEND__/product/detail/{{$v.Ident}}" target="_blank">{{$v.Name}}</a></td>
							<td>{{$v.Ident}}</td>
							<td>{{$v.Price}}</td>
							<td>
								<div class="checkbox checkbox-success no-margin-y">
									<input id="checkbox-{{$k}}" class="styled switch-status" type="checkbox" data-id="{{$v.Id}}" data-status="{{$v.Status}}"{{if eq $v.Status "normal"}} checked="checked"{{end}} value="normal" /><label for="checkbox-{{$k}}">{{"启用"|T}}</label>
								</div>
							</td>
							<td>{{"创建"|T}}: {{(Date $v.Created).Format "2006-01-02 15:04:05"}}{{if gt $v.Updated 0}}<br />{{"修改"|T}}: {{(Date $v.Updated).Format "2006-01-02 15:04:05"}}{{end}}</td>
							<td class="text-center">
							<a class="label label-primary" href="__BACKEND__/official/pay/product_version_index?productId={{$v.Id}}" title="{{"版本管理"|T}}" data-toggle="tooltip"><i class="fa fa-list"></i></a>
							<a class="label label-info" href="__BACKEND__/official/news_index?productId={{$v.Id}}" title="{{"资讯管理"|T}}" data-toggle="tooltip"><i class="fa fa-rss-square"></i></a>
							<a class="label label-default" href="__BACKEND__/official/pay/product_add?copyId={{$v.Id}}" title="{{"复制"|T}}" data-toggle="tooltip"><i class="fa fa-copy"></i></a>
							<a class="label label-success" href="__BACKEND__/official/pay/product_edit?id={{$v.Id}}" title="{{"编辑"|T}}" data-toggle="tooltip"><i class="fa fa-pencil"></i></a> 
							<a class="label label-danger" href="__BACKEND__/official/pay/product_delete?id={{$v.Id}}" onclick="return confirm('{{"真的要删除吗？"|T}}');" title="{{"删除"|T}}" data-toggle="tooltip"><i class="fa fa-times"></i></a>
							</td>
						</tr>
                        {{end}}
					</tbody>
				</table>		
				</div>
				{{Stored.pagination.Render}}
			</div>
		</div>				
	</div>
</div>
{{/Block}}
{{Block "footer"}}
<script>
$(function(){
	$('input.switch-status').on('click',function(r){
		var that=$(this),status=that.data('status')=='normal'?'hidden':'normal';
		$.get(BACKEND_URL+'/official/pay/product_edit',{
			status:status,
			id:that.data('id')
		},function(r){
			if(r.Code==1){
				that.data('status',status);
				that.prop('checked',status=='normal');
			}
			App.message({title:'{{"系统消息"|T}}',text:r.Info,time:5000,sticky:false,class_name:r.Code==1?'success':'error'});
		},'json');
	});
});
</script>
{{/Block}}